package org.com.behavioralPattern.chainofResponsibilityPattern;

/**
 * 责任链模式——击鼓传花饮酒游
 * @author Jonny
 * @version 1.0
 * @Description: 传花者
 * @date 2021/4/27 11:43
 */
public abstract class Player {
    private Player successor;
    public abstract void handle(int i);
    protected void setSuccessor(Player aSuccessor){
        successor=aSuccessor;
    }

    public void next(int index){
        if(successor!=null){
            successor.handle(index);
        }else{
            System.out.println("游戏结束！");
        }
    }
}
